package com.tristia.entity;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@MappedSuperclass
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "txt", propOrder = {
    "id",
    "title"
})
@XmlRootElement
public class Txt {
    
	@Id 
	@GeneratedValue(strategy = GenerationType.AUTO)
	private long id;
	@XmlElement(required = true)
    private String title;

    public Txt() {
    }

    public Txt(final String title, final long author) {
        this.title = title;
    }
    
	public void setId(long id) {
		this.id = id;
	}

	public long getId() {
		return id;
	}

    public void setTitle(String title) {
		this.title = title;
	}
    
	public String getTitle() {
        return title;
    }
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		result = prime * result + ((title == null) ? 0 : title.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Txt other = (Txt) obj;
		if (id != other.id)
			return false;
		if (title == null) {
			if (other.title != null)
				return false;
		} else if (!title.equals(other.title))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Txt [id=" + id + ", title=" + title + "]";
	}

	@GET
    @Produces({MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.APPLICATION_JSON})
    public Txt getXml() {
        return this;
    }
}
